<?php


namespace logicmodel\award;


class Recommend extends Award
{
    private $award_id;
    public function __construct()
    {
        parent::__construct();
        $this->award_id  = 1;
    }

    /**
     *推荐奖励
     * @param $uid
     * @param $from_uid
     * @param $remark
     * @param $type
     * @return bool
     * @throws \think\Exception
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public function award($uid,$from_uid,$remark,$type=1){
       $awardInfo =  $this->awardIsOpen($this->award_id);
        if($awardInfo === false) return false;
        $recommend_award = $type == 1 ?config('site.recommend_award'):config('site.first_buy_award');
       if($recommend_award > 0) $this->record($uid,2,$recommend_award,$from_uid,$this->award_id,$awardInfo['name'],$remark,$awardInfo['field']);
        return true;
    }
}